package com.wd.health.view.activity.home;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.wd.health.R;
import com.wd.health.model.bean.BzxqBean;
import com.wd.health.utils.RetrofitManager;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class CjbzxqActivity extends AppCompatActivity {

    private TextView name;
    private TextView bl;
    private TextView bz;
    private TextView yyj;
    private TextView xy;
    private TextView zy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cjbzxq);
        initView();
        initData();
    }

    private void initData() {
        Intent intent = getIntent();
        int id = intent.getIntExtra("id",0);
        String mName = intent.getStringExtra("name");
        name.setText(mName+"");

        RetrofitManager.getInstance().getBzxqData(id, new Observer<BzxqBean>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(BzxqBean bzxqBean) {
                BzxqBean.ResultBean result = bzxqBean.getResult();
                if (result.getPathology()!=null){
                    bl.setText(result.getPathology());
                }else {
                    bl.setText("无");
                }

                if (result.getSymptom()!=null){
                    bz.setText(result.getSymptom());
                }else {
                    bz.setText("无");
                }

                if (result.getBenefitTaboo()!=null){
                    yyj.setText(result.getBenefitTaboo());
                }else {
                    yyj.setText("无");
                }

                if (result.getWesternMedicineTreatment()!=null){
                    xy.setText(result.getWesternMedicineTreatment());
                }else {
                    xy.setText("无");
                }

                if (result.getChineseMedicineTreatment()!=null){
                    zy.setText(result.getChineseMedicineTreatment());
                }else {
                    zy.setText("无");
                }



            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    private void initView() {
        name = findViewById(R.id.tv_bz_name);
        bl = findViewById(R.id.tv_bz_bl);
        bz = findViewById(R.id.tv_bz_bz);
        yyj = findViewById(R.id.tv_bz_yyj);
        xy = findViewById(R.id.tv_bz_xy);
        zy = findViewById(R.id.tv_bz_zy);

    }
}